//
//  BaseInfo.m
//  MIC_MoveModelExample
//
//  Created by 李爽 on 15/11/16.
//  Copyright (c) 2015年 Shawn Li. All rights reserved.
//  实体基类

#import "BaseInfo.h"

@implementation BaseInfo

+ (instancetype)infoFromDict:(NSDictionary *)dict {
    BaseInfo *info = [[BaseInfo alloc] init];
    
    info.ID = [dict objectForKey:@"id"];
    info.name = [dict objectForKey:@"name"];
    
    return info;
}

+ (NSArray *)arrayFromDict:(NSDictionary *)dict {
    NSArray *array = [dict objectForKey:@""];
    return [[self class] arrayFromArray:array];
}

+ (NSArray *)arrayFromArray:(NSArray *)array {
    NSMutableArray *infos = [[NSMutableArray alloc] init];
    
    for (NSDictionary *dic in array) {
        [infos addObject:[[self class] infoFromDict:dic]];
    }
    
    if (infos.count <= 0) {
        infos = nil;
    }
    
    return infos;
}

- (NSComparisonResult)compare:(BaseInfo *)baseInfo {
    return [self.ID caseInsensitiveCompare:baseInfo.ID];
}

- (BOOL)isEqual:(BaseInfo *)baseInfo {
    return [self.ID isEqualToString:baseInfo.ID];
}

@end
